package kr.hkit.powerjava.coffee.service;

import java.sql.Connection;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;

import kr.hkit.powerjava.coffee.dao.ProductDao;
import kr.hkit.powerjava.coffee.dto.Product;

public class ProductService {
	private ArrayList<Product> list;
	private ProductDao dao;

	public ProductService(Connection connection) {
		dao = new ProductDao(connection);
	}
	
	public void insertItem(Product item) throws SQLException {
//		DecimalFormat df =
				
		item.setSellingPrice(item.getPrice() * item.getAmount());
		item.setSurtax(item.getSellingPrice() / 11);
		item.setSupply(item.getSellingPrice() - item.getSurtax());
		item.setMargin(item.getMargin()); 
		item.setMarginSum(item.getSupply() * item.getMargin() / 100);
		dao.insertItem(item);
	}
}
